package com.heyu.cloud.config;

public class MybatisCamelCaseTable extends MybatisTable {

	public MybatisCamelCaseTable(String tableName) {
		super(tableName, camelCase(tableName));
	}

	private static final String camelCase(String tableName) {
		StringBuilder builder = new StringBuilder();
		char[] chars = tableName.toCharArray();
		boolean upcase = false;
		for(char ch : chars) {
			if(ch == '_') {
				upcase = true;
				continue;
			}
			if(builder.length() == 0 || upcase) {
				builder.append(Character.toUpperCase(ch));
				upcase = false;
			} else {
				builder.append(Character.toLowerCase(ch));
			}
		}
		return builder.toString();
	}

}
